<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- 兼容性 -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <title>基础设置-项目构成</title>
    <script src="/scripts/boot.js"></script>
    <style>
        html,body{
            margin:0;padding: 0;border:0;width:100%;height:100%;overflow:hidden;
        }
        body{
            background: #ffffff!important;
            padding:20px;
        }
    </style>
</head>
<body>
<div class="title-list mb-20"><span class="title-listbg"></span><span>项目月度计划</span></div>
<div id="qForm"  class="mini-toolbar1" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
                <div class="mb-20 position-rel">
                    <span class="search-title search-ml20">项目名称</span><select id="itemIId" name="itemIId" class="mini-combobox w200" ajaxType="post" url="/item/list" emptyText="全部" showNullItem="true" nullItemText="全部" textField="name" valueField="id"></select>
                    <span class="search-title search-ml60">节点名称</span><input id="inputNodeName" name="inputNodeName" class="mini-textbox search-200px"/>
                    <span class="search-title search-ml60">选择年月</span><div id="yearItem"></div>
                    <a class="add-botton search-ml60" onclick="list.search()">查询</a>
                    <a class="resetting-btn search-ml20" onclick="list.reset()">重置</a>
                </div>
            </td>
        </tr>
    </table>
</div>
<div class="container">
    <div class="mini-clearfix mb-10">
        <div class="mini-col-6 mini-col-sm-6">
        <!--    <span>2018</span>月<span>02</span>日<span>1112</span>元-->
            <!--<a class="stamp-export mR-20"  onclick="list.print()"><span class="stamp-bg"></span><span class="span-line">打印</span></a>-->
            <!--<a class="bill-export mR-20"  onclick="list.downExcel()"><span class="bill-bg"></span><span class="span-line">导出</span></a>-->
        </div>
    </div>
</div>
<div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;"  url="/check/monthListByPage" sizeList="[5,10,20,50]" pageSize="20"  idField="user_id" multiSelect="true" showEmptyText="true" emptyText="暂无数据" alwaysShowEmptyText="true"  multiSelect="true"   showSummaryRow="true"  allowResize="true" ondrawsummarycell="onDrawSummaryCell" >

        <div property="columns">
            <div type="indexcolumn" headerAlign="center" width="50" align="center">编号</div>
            <div field="planName" width="150" headerAlign="center" allowSort="false">计划名称</div>
            <div field="business" width="120" headerAlign="center" align="center" allowSort="false">业务板块</div>
            <div field="nodeName" width="120" headerAlign="center" allowSort="false">节点名称</div>
            <div field="beginEndDate" width="120" headerAlign="center" align="center" allowSort="false" renderer="ondayRenderer">计划起止时间</div>
            <div field="rate" width="120" headerAlign="center" align="center" allowSort="false">进度</div>
            <div field="overDay" width="120" headerAlign="center" align="center" allowSort="false">状态</div>
            <!--<div field="remark" width="120" headerAlign="center" allowSort="false">备注</div>-->
            <div field="fineMoney" width="120" headerAlign="center" align="center" allowSort="false">考核金额(元)</div>
            <input  field="value" visible="false"/>
            <div name="action" width="200" headerAlign="center" align="center">操作</div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //list.init();
    var grid;
    var list = {
        //页面初始化
        init: function() {
            mini.parse();
            common.changeYears();
            grid = mini.get("datagrid1");
            var now = new Date();
            var time = now.getFullYear() + "-" +((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1);
            grid.load({"dateTemp": time});
            mini.get("datagrid1").on("drawcell", function (e) {
                var column = e.column;
                if(column.field=="beginEndDate"){
                    e.cellHtml = e.row.beginDate.substring(0,10)+'至'+e.row.endDate.substring(0,10);
                }
                if(column.field=="rate"){
                    e.cellHtml = e.row.rate+"%";
                }
                if(column.field=="overDay"){
                    e.cellHtml = "逾期"+e.row.overDay+"天";
                }
                if (column.name == "action") {
                    e.cellHtml = '<a class="check-botton" href="javascript:list.view()">查看明细</a>'+
                        '<a class="check-botton btn-bd" href="javascript:list.planInfo()">计划详情</a>';
                }
			})
        },
        //    计划详情
        planInfo: function (opt) {
            mini.open({
                url: "/program/monthlyPlan/view.html",
                title: "计划详情", width: 1100, height: 600,
                onload: function () {
                    var row = grid.getSelected();
                    var data = {"id": row.id};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.view.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        //    查看详情
        view: function(){
            mini.open({
                url: "/planAssessment/keyPoint/view.html",
                title: "考核明细", width: 1100, height: 700,
                onload: function () {
                    var row = grid.getSelected();
                    var data = {"id": row.id,"nodeName":row.nodeName,"beginDate":row.beginDate,"endDate":row.endDate,"rate":row.rate,"overDay":row.overDay,"fineMoney":row.fineMoney,"value":row.value};
                    //  var data = {"id": id};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.list.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        //    查询
        search: function () {
        	 var years = mini.get("year").getValue();
             var mouths = mini.get("month").getValue();
             var date = years+"-"+mouths
             var data = {
                "plan.item.id": mini.get("itemIId").getValue(),
                "nodeName": mini.get("inputNodeName").getValue(),
                "dateTemp": date,
               };
            grid.load(data); 
        },
        //重置
        reset:function(){
            mini.get("year").select(0);
            var years = mini.get("year").getValue();
            var endMonth = new Date().getMonth()+1;
            mini.get("month").setValue(endMonth);
            mini.get("itemIId").setValue("");
            mini.get("inputNodeName").setValue("");
            var now = new Date();
            var time = now.getFullYear() + "-" +((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1);
            grid.load({"dateTemp": time});
        }
    };
    list.init();
    function onDrawSummaryCell(e) {
        var result = e.result;
        var column = e.column;
        var years = mini.get("year").getValue();
        var mouths = mini.get("month").getValue();
        //服务端汇总计算
        if (column.field == "fineMoney") {
            var sum = 0;
            var mymoney =result.fineMoney;
            for(var i=0;i< result.data.length;i++){
                sum+= Number(result.data[i].fineMoney);
            }

            e.cellHtml = years+"年"+mouths+"月"+"总计"+sum+"元";
        }
    }
</script>
</body>
</html>